home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / PInterfaces / NameRegistry.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  12.5 KB  |  362 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        NameRegistry.p
  3.  
  4.      Contains:    NameRegistry Interfaces
  5.  
  6.      Version:    Technology:    MacOS
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1993-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT NameRegistry;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __NAMEREGISTRY__}
  27. {$SETC __NAMEREGISTRY__ := 1}
  28.  
  29. {$I+}
  30. {$SETC NameRegistryIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __MACTYPES__}
  34. {$I MacTypes.p}
  35. {$ENDC}
  36.  
  37.  
  38. {$PUSH}
  39. {$ALIGN POWER}
  40. {$LibExport+}
  41.  
  42. {******************************************************************************
  43.  * 
  44.  * Foundation Types
  45.  *
  46.  }
  47. { Value of a property }
  48.  
  49. TYPE
  50.     RegPropertyValue                    = Ptr;
  51. { Length of property value }
  52.     RegPropertyValueSize                = UInt32;
  53. {******************************************************************************
  54.  * 
  55.  * RegEntryID    :    The Global x-Namespace Entry Identifier
  56.  *
  57.  }
  58.     RegEntryIDPtr = ^RegEntryID;
  59.     RegEntryID = RECORD
  60.         contents:                ARRAY [0..3] OF UInt32;
  61.     END;
  62.  
  63. {******************************************************************************
  64.  *
  65.  * Root Entry Name Definitions    (Applies to all Names in the RootNameSpace)
  66.  *
  67.  *    • Names are a colon-separated list of name components.  Name components
  68.  *      may not themselves contain colons.  
  69.  *    • Names are presented as null-terminated ASCII character strings.
  70.  *    • Names follow similar parsing rules to Apple file system absolute
  71.  *      and relative paths.  However the '::' parent directory syntax is
  72.  *      not currently supported.
  73.  }
  74. { Max length of Entry Name }
  75.  
  76. CONST
  77.     kRegCStrMaxEntryNameLength    = 47;
  78.  
  79. { Entry Names are single byte ASCII }
  80.  
  81. TYPE
  82.     RegCStrEntryName                    = CHAR;
  83.     RegCStrEntryNamePtr                    = ^CHAR;
  84. {  length of RegCStrEntryNameBuf =  kRegCStrMaxEntryNameLength+1 }
  85.     RegCStrEntryNameBuf                    = PACKED ARRAY [0..47] OF CHAR;
  86.     RegCStrPathName                        = CHAR;
  87.     RegPathNameSize                        = UInt32;
  88.  
  89. CONST
  90.     kRegPathNameSeparator        = 58;                            {  0x3A  }
  91.     kRegEntryNameTerminator        = $00;                            {  '\0'  }
  92.     kRegPathNameTerminator        = $00;                            {  '\0'  }
  93.  
  94. {******************************************************************************
  95.  *
  96.  * Property Name and ID Definitions
  97.  *    (Applies to all Properties Regardless of NameSpace)
  98.  }
  99.     kRegMaximumPropertyNameLength = 31;                            {  Max length of Property Name  }
  100.     kRegPropertyNameTerminator    = $00;                            {  '\0'  }
  101.  
  102.  
  103. TYPE
  104.     RegPropertyNameBuf                    = PACKED ARRAY [0..31] OF CHAR;
  105.     RegPropertyName                        = CHAR;
  106.     RegPropertyNamePtr                    = ^CHAR;
  107. {******************************************************************************
  108.  *
  109.  * Iteration Operations
  110.  *
  111.  *    These specify direction when traversing the name relationships
  112.  }
  113.     RegIterationOp                        = UInt32;
  114.     RegEntryIterationOp                    = RegIterationOp;
  115.  
  116. CONST
  117.                                                                 {  Absolute locations }
  118.     kRegIterRoot                = $00000002;                    {  "Upward" Relationships     }
  119.     kRegIterParents                = $00000003;                    {  include all  parent(s) of entry  }
  120.                                                                 {  "Downward" Relationships }
  121.     kRegIterChildren            = $00000004;                    {  include all children  }
  122.     kRegIterSubTrees            = $00000005;                    {  include all sub trees of entry  }
  123.     kRegIterDescendants            = $00000005;                    {  include all descendants of entry  }
  124.                                                                 {  "Horizontal" Relationships     }
  125.     kRegIterSibling                = $00000006;                    {  include all siblings  }
  126.                                                                 {  Keep doing the same thing }
  127.     kRegIterContinue            = $00000001;
  128.  
  129. {******************************************************************************
  130.  *
  131.  * Name Entry and Property Modifiers
  132.  *
  133.  *
  134.  *
  135.  * Modifiers describe special characteristics of names
  136.  * and properties.  Modifiers might be supported for
  137.  * some names and not others.
  138.  * 
  139.  * Device Drivers should not rely on functionality
  140.  * specified as a modifier.
  141.  }
  142.  
  143. TYPE
  144.     RegModifiers                        = UInt32;
  145.     RegEntryModifiers                    = RegModifiers;
  146.     RegPropertyModifiers                = RegModifiers;
  147.  
  148. CONST
  149.     kRegNoModifiers                = $00000000;                    {  no entry modifiers in place  }
  150.     kRegUniversalModifierMask    = $0000FFFF;                    {  mods to all entries  }
  151.     kRegNameSpaceModifierMask    = $00FF0000;                    {  mods to all entries within namespace  }
  152.     kRegModifierMask            = $FF000000;                    {  mods to just this entry  }
  153.  
  154. { Universal Property Modifiers }
  155.     kRegPropertyValueIsSavedToNVRAM = $00000020;                {  property is non-volatile (saved in NVRAM)  }
  156.     kRegPropertyValueIsSavedToDisk = $00000040;                    {  property is non-volatile (saved on disk)  }
  157.  
  158. { ///////////////////////
  159. //
  160. // The Registry API
  161. //
  162. /////////////////////// }
  163. { ///////////////////////
  164. //
  165. // Entry Management
  166. //
  167. /////////////////////// }
  168.  
  169. {-------------------------------
  170.  * EntryID handling
  171.  }
  172. {
  173.  * Initialize an EntryID to a known invalid state
  174.  *   note: invalid != uninitialized
  175.  }
  176. FUNCTION RegistryEntryIDInit(VAR id: RegEntryID): OSStatus; C;
  177. {
  178.  * Compare EntryID's for equality or if invalid
  179.  *
  180.  * If a NULL value is given for either id1 or id2, the other id 
  181.  * is compared with an invalid ID.  If both are NULL, the id's 
  182.  * are consided equal (result = true). 
  183.  }
  184. FUNCTION RegistryEntryIDCompare({CONST}VAR id1: RegEntryID; {CONST}VAR id2: RegEntryID): BOOLEAN; C;
  185. {
  186.  * Copy an EntryID
  187.  }
  188. FUNCTION RegistryEntryIDCopy({CONST}VAR src: RegEntryID; VAR dst: RegEntryID): OSStatus; C;
  189. {
  190.  * Free an ID so it can be reused.
  191.  }
  192. FUNCTION RegistryEntryIDDispose(VAR id: RegEntryID): OSStatus; C;
  193. {-------------------------------
  194.  * Adding and removing entries
  195.  *
  196.  * If (parentEntry) is NULL, the name is assumed
  197.  * to be a rooted path. It is rooted to an anonymous, unnamed root.
  198.  }
  199. FUNCTION RegistryCStrEntryCreate({CONST}VAR parentEntry: RegEntryID; {CONST}VAR name: RegCStrPathName; VAR newEntry: RegEntryID): OSStatus; C;
  200. FUNCTION RegistryEntryDelete({CONST}VAR id: RegEntryID): OSStatus; C;
  201. FUNCTION RegistryEntryCopy(VAR parentEntryID: RegEntryID; VAR sourceDevice: RegEntryID; VAR destDevice: RegEntryID): OSStatus; C;
  202. {---------------------------
  203.  * Traversing the namespace
  204.  *
  205.  * To support arbitrary namespace implementations in the future,
  206.  * I have hidden the form that the place pointer takes.  The previous
  207.  * interface exposed the place pointer by specifying it as a
  208.  * RegEntryID.
  209.  *
  210.  * I have also removed any notion of returning the entries
  211.  * in a particular order, because an implementation might
  212.  * return the names in semi-random order.  Many name service
  213.  * implementations will store the names in a hashed lookup
  214.  * table.
  215.  *
  216.  * Writing code to traverse some set of names consists of
  217.  * a call to begin the iteration, the iteration loop, and
  218.  * a call to end the iteration.  The begin call initializes
  219.  * the iteration cookie data structure.  The call to end the 
  220.  * iteration should be called even in the case of error so 
  221.  * that allocated data structures can be freed.
  222.  *
  223.  *    Create(...)
  224.  *    do (
  225.  *        Iterate(...);
  226.  *    ) while (!done);
  227.  *    Dispose(...);
  228.  *
  229.  * This is the basic code structure for callers of the iteration
  230.  * interface.
  231.  }
  232.  
  233. TYPE
  234.     RegEntryIter = ^LONGINT;
  235.  * create/dispose the iterator structure
  236.  *   defaults to root with relationship = kRegIterDescendants
  237.  }
  238. FUNCTION RegistryEntryIterateCreate(VAR cookie: RegEntryIter): OSStatus; C;
  239. FUNCTION RegistryEntryIterateDispose(VAR cookie: RegEntryIter): OSStatus; C;
  240.  * set Entry Iterator to specified entry
  241.  }
  242. FUNCTION RegistryEntryIterateSet(VAR cookie: RegEntryIter; {CONST}VAR startEntryID: RegEntryID): OSStatus; C;
  243. {
  244.  * Return each value of the iteration
  245.  *
  246.  * return entries related to the current entry
  247.  * with the specified relationship
  248.  }
  249. FUNCTION RegistryEntryIterate(VAR cookie: RegEntryIter; relationship: RegEntryIterationOp; VAR foundEntry: RegEntryID; VAR done: BOOLEAN): OSStatus; C;
  250. {
  251.  * return entries with the specified property
  252.  *
  253.  * A NULL RegPropertyValue pointer will return an
  254.  * entry with the property containing any value.
  255.  }
  256. FUNCTION RegistryEntrySearch(VAR cookie: RegEntryIter; relationship: RegEntryIterationOp; VAR foundEntry: RegEntryID; VAR done: BOOLEAN; {CONST}VAR propertyName: RegPropertyName; propertyValue: UNIV Ptr; propertySize: RegPropertyValueSize): OSStatus; C;
  257. {--------------------------------
  258.  * Find a name in the namespace
  259.  *
  260.  * This is the fast lookup mechanism.
  261.  * NOTE:  A reverse lookup mechanism
  262.  *      has not been provided because
  263.  *        some name services may not
  264.  *        provide a fast, general reverse
  265.  *        lookup.
  266.  }
  267. FUNCTION RegistryCStrEntryLookup({CONST}VAR searchPointID: RegEntryID; {CONST}VAR pathName: RegCStrPathName; VAR foundEntry: RegEntryID): OSStatus; C;
  268. {---------------------------------------------
  269.  * Convert an entry to a rooted name string
  270.  *
  271.  * A utility routine to turn an Entry ID
  272.  * back into a name string.
  273.  }
  274. FUNCTION RegistryEntryToPathSize({CONST}VAR entryID: RegEntryID; VAR pathSize: RegPathNameSize): OSStatus; C;
  275. FUNCTION RegistryCStrEntryToPath({CONST}VAR entryID: RegEntryID; VAR pathName: RegCStrPathName; pathSize: RegPathNameSize): OSStatus; C;
  276. {
  277.  * Parse a path name.
  278.  *
  279.  * Retrieve the last component of the path, and
  280.  * return a spec for the parent.
  281.  }
  282. FUNCTION RegistryCStrEntryToName({CONST}VAR entryID: RegEntryID; VAR parentEntry: RegEntryID; VAR nameComponent: RegCStrEntryName; VAR done: BOOLEAN): OSStatus; C;
  283. { //////////////////////////////////////////////////////
  284. //
  285. // Property Management
  286. //
  287. ////////////////////////////////////////////////////// }
  288. {-------------------------------
  289.  * Adding and removing properties
  290.  }
  291. FUNCTION RegistryPropertyCreate({CONST}VAR entryID: RegEntryID; {CONST}VAR propertyName: RegPropertyName; propertyValue: UNIV Ptr; propertySize: RegPropertyValueSize): OSStatus; C;
  292. FUNCTION RegistryPropertyDelete({CONST}VAR entryID: RegEntryID; {CONST}VAR propertyName: RegPropertyName): OSStatus; C;
  293. FUNCTION RegistryPropertyRename({CONST}VAR entry: RegEntryID; {CONST}VAR oldName: RegPropertyName; {CONST}VAR newName: RegPropertyName): OSStatus; C;
  294. {---------------------------
  295.  * Traversing the Properties of a name
  296.  *
  297.  }
  298.  
  299. TYPE
  300.     RegPropertyIter = ^LONGINT;
  301. FUNCTION RegistryPropertyIterateCreate({CONST}VAR entry: RegEntryID; VAR cookie: RegPropertyIter): OSStatus; C;
  302. FUNCTION RegistryPropertyIterateDispose(VAR cookie: RegPropertyIter): OSStatus; C;
  303. FUNCTION RegistryPropertyIterate(VAR cookie: RegPropertyIter; VAR foundProperty: RegPropertyName; VAR done: BOOLEAN): OSStatus; C;
  304. {
  305.  * Get the value of the specified property for the specified entry.
  306.  *
  307.  }
  308. FUNCTION RegistryPropertyGetSize({CONST}VAR entryID: RegEntryID; {CONST}VAR propertyName: RegPropertyName; VAR propertySize: RegPropertyValueSize): OSStatus; C;
  309. {
  310.  * (*propertySize) is the maximum size of the value returned in the buffer
  311.  * pointed to by (propertyValue).  Upon return, (*propertySize) is the size of the
  312.  * value returned.
  313.  }
  314. FUNCTION RegistryPropertyGet({CONST}VAR entryID: RegEntryID; {CONST}VAR propertyName: RegPropertyName; propertyValue: UNIV Ptr; VAR propertySize: RegPropertyValueSize): OSStatus; C;
  315. FUNCTION RegistryPropertySet({CONST}VAR entryID: RegEntryID; {CONST}VAR propertyName: RegPropertyName; propertyValue: UNIV Ptr; propertySize: RegPropertyValueSize): OSStatus; C;
  316. { //////////////////////////////////////////////////////
  317. //
  318. // Modifier Management
  319. //
  320. ////////////////////////////////////////////////////// }
  321. {
  322.  * Modifiers describe special characteristics of names
  323.  * and properties.  Modifiers might be supported for
  324.  * some names and not others.
  325.  * 
  326.  * Device Drivers should not rely on functionality
  327.  * specified as a modifier.  These interfaces
  328.  * are for use in writing Experts.
  329.  }
  330. {
  331.  * Get and Set operators for entry modifiers
  332.  }
  333. FUNCTION RegistryEntryGetMod({CONST}VAR entry: RegEntryID; VAR modifiers: RegEntryModifiers): OSStatus; C;
  334. FUNCTION RegistryEntrySetMod({CONST}VAR entry: RegEntryID; modifiers: RegEntryModifiers): OSStatus; C;
  335. {
  336.  * Get and Set operators for property modifiers
  337.  }
  338. FUNCTION RegistryPropertyGetMod({CONST}VAR entry: RegEntryID; {CONST}VAR name: RegPropertyName; VAR modifiers: RegPropertyModifiers): OSStatus; C;
  339. FUNCTION RegistryPropertySetMod({CONST}VAR entry: RegEntryID; {CONST}VAR name: RegPropertyName; modifiers: RegPropertyModifiers): OSStatus; C;
  340. {
  341.  * Iterator operator for entry modifier search
  342.  }
  343. FUNCTION RegistryEntryMod(VAR cookie: RegEntryIter; relationship: RegEntryIterationOp; VAR foundEntry: RegEntryID; VAR done: BOOLEAN; matchingModifiers: RegEntryModifiers): OSStatus; C;
  344. {
  345.  * Iterator operator for entries with matching 
  346.  * property modifiers
  347.  }
  348. FUNCTION RegistryEntryPropertyMod(VAR cookie: RegEntryIter; relationship: RegEntryIterationOp; VAR foundEntry: RegEntryID; VAR done: BOOLEAN; matchingModifiers: RegPropertyModifiers): OSStatus; C;
  349.  
  350. {$ALIGN RESET}
  351. {$POP}
  352.  
  353. {$SETC UsingIncludes := NameRegistryIncludes}
  354.  
  355. {$ENDC} {__NAMEREGISTRY__}
  356.  
  357. {$IFC NOT UsingIncludes}
  358.  END.
  359. {$ENDC}
  360.